int D1 = 2;
int D2 = 3;
int D3 = 4;

int lastD;

void setup() {
  // put your setup code here, to run once:
  pinMode(D1, INPUT_PULLUP);
  pinMode(D2, INPUT_PULLUP);
  pinMode(D3, INPUT_PULLUP);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  int currentD = 0;

  if (digitalRead(D1) == LOW) {
    currentD = 1;
  }

  if (digitalRead(D2) == LOW) {
    currentD = 2;
  }

  if (digitalRead(D3) == LOW) {
    currentD = 3;
  }

  if (currentD != lastD && currentD != 0) {
    Serial.println(currentD);
    lastD = currentD;
    delay(50);
  }


}